package ua.kpi_java_training.zastupaylo.module1;

import org.junit.Test;
import static org.junit.Assert.*;

import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;


/**
 * Tests for Division.class
 *
 * @version 1.0
 * @author Zastupaylo Alexander (zastupaylo@gmailcom)
 */
/*public class DivisionTest {


    @Test
    public void testInput() throws Exception {
    //don't know how to implement input test unit yet
    }

    @Test
    public void testCheckInput() throws Exception {
    //don't know how to implement input test unit yet
    }

    @Test
    public void testGetResultWithoutDivision() throws Exception {
        Division.dividend = 0;
        Division.divisor = 1;
        assertTrue(Division.getResultWithoutDivision());
        Division.dividend = 5;
        Division.divisor = 6;
        assertTrue(Division.getResultWithoutDivision());
        Division.dividend = 7;
        Division.divisor = 6;
        assertFalse(Division.getResultWithoutDivision());
    }

    @Test
    public void testCheckSign() throws Exception {
        Division.checkSign(6, 1);
        assertTrue(Division.positiveSign);
        Division.checkSign(-6, -1);
        assertTrue(Division.positiveSign);
        Division.checkSign(-1, 6);
        assertFalse(Division.positiveSign);
        Division.checkSign(6, -1);
        assertFalse(Division.positiveSign);
    }

    @Test
    public void testPrintDivisionForm() throws Exception {
        String expectedOutput = "\n1234 | 11\n";
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(baos));
        Division.dividend = 1234;
        Division.divisor = 11;
        Division.printDivisionForm();
        baos.flush();
        String actualOutput = new String(baos.toByteArray());
        assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void testConvertDividendToDigits() throws Exception {
        ArrayList<Integer> testDividendDigits = new ArrayList<Integer>() {{
            add(4);
            add(3);
            add(2);
            add(1);
        }};
        Division.convertDividendToDigits(1234);
        assertEquals(Division.dividendDigits, testDividendDigits);
    }

    @Test
    public void testDrawLine() throws Exception {
        String expectedOutput = "--\n";
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(baos));
        Division.drawLine(15);
        baos.flush();
        String actualOutput = new String(baos.toByteArray());
        assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void testGetNumberLength() throws Exception {
        assertEquals(Division.getNumberLength(123), 3);
    }

    @Test
    public void testPrintBackspaces() throws Exception {
        String expectedOutput = String.format("%" + 3 + "s", "");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(baos));
        Division.printBackspaces(3);
        baos.flush();
        String actualOutput = new String(baos.toByteArray());
        assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void testMakeDivision() throws Exception {
        ArrayList<Integer> testIntermediateValues = new ArrayList<Integer>() {{
            add(12);
            add(11);
            add(13);
            add(11);
            add(24);
            add(22);
            add(2);
        }};
        Division.dividend = 1234;
        Division.divisor = 11;
        assertEquals(Division.makeDivision(), testIntermediateValues);
    }

    @Test
    public void testOutputIntermediateValues() throws Exception {
        String expectedOutput = "11\n--\n 13\n 11\n --\n  24\n  22\n  --\n   2\n";
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(baos));
        ArrayList<Integer> testIntermediateValues = new ArrayList<Integer>() {{
            add(12);
            add(11);
            add(13);
            add(11);
            add(24);
            add(22);
            add(2);
        }};
        Division.outputIntermediateValues(testIntermediateValues);
        baos.flush();
        String actualOutput = new String(baos.toByteArray());
        assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void testOutputResult() throws Exception {
        Division.positiveSign = true;
        String expectedOutput = "Result of dividing: 112";
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(baos));
        ArrayList<Integer> testIntermediateValues = new ArrayList<Integer>() {{
            add(12);
            add(11);
            add(13);
            add(11);
            add(24);
            add(22);
            add(2);
        }};
        Division.outputResult(testIntermediateValues);
        baos.flush();
        String actualOutput = new String(baos.toByteArray());
        assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void testOutput() throws Exception {
        ArrayList<Integer> testIntermediateValues = new ArrayList<Integer>() {{
            add(12);
            add(11);
            add(13);
            add(11);
            add(24);
            add(22);
            add(2);
        }};
        String expectedOutput = "11\n--\n 13\n 11\n --\n  24\n  22\n  --\n   2\nResult of dividing: 112";
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(baos));
        Division.output(testIntermediateValues);
        baos.flush();
        String actualOutput = new String(baos.toByteArray());
        assertEquals(expectedOutput, actualOutput);
    }
}
 */